package com.daoeping.action;

import java.util.ArrayList;
import java.util.List;

import com.daoeping.data.Bsc_city;
import com.daoeping.domain.JsonData;
import com.daoeping.service.Bsc_cityService;
import com.daoeping.util.ConverntJsonData;
import com.opensymphony.xwork2.ActionSupport;

public class Bsc_cityAction extends ActionSupport{

	private Bsc_cityService bsc_cityService;
	private JsonData jsonData;
	private List<Object[]> bsc_cityList;
	
	public List<Object[]> getBsc_cityList() {
		return bsc_cityList;
	}


	public void setBsc_cityList(List<Object[]> bsc_cityList) {
		this.bsc_cityList = bsc_cityList;
	}


	public JsonData getJsonData() {
		return jsonData;
	}


	public void setJsonData(JsonData jsonData) {
		this.jsonData = jsonData;
	}


	public Bsc_cityService getBsc_cityService() {
		return bsc_cityService;
	}


	public void setBsc_cityService(Bsc_cityService bsc_cityService) {
		this.bsc_cityService = bsc_cityService;
	}


	public List<Bsc_city> findBsc_addressList(){
		return this.bsc_cityService.findBsc_addressList();
	}
	
	public String findBsc_cityList(){
		jsonData = new JsonData();
		bsc_cityList = bsc_cityService.findBsc_cityList();
		List<List<String>> newlist = new ArrayList<List<String>>();
		List<String> list = new ArrayList<String>();
		for (int i = 0; i < bsc_cityList.size(); i++) {
			Object[] obj = bsc_cityList.get(i);
			if(list.size()==0){
				list.add(obj[0]+","+obj[1]);
			}
			list.add(obj[2]+","+obj[3]);
			if((i<bsc_cityList.size()-1&&!bsc_cityList.get(i)[0].equals(bsc_cityList.get(i+1)[0]))||i == bsc_cityList.size()-1){
				newlist.add(list);
				list = new ArrayList<String>();
			}
		}
		jsonData.setJsonData(new ConverntJsonData().getJsonData(newlist)+"");
		
		return "findBsc_cityList";
		
	}
	
}
